package com.synchrona;

import com.synchrona.common.EnumService;
import com.synchrona.common.Queue;
import com.synchrona.common.SynchronizationThread;
import com.synchrona.update.Update;
import com.synchrona.updateSyncManager.UpdateSyncManager;
import com.synchrona.user.User;

public class SynchronizationProcessor {
	private Queue queue;
	private static final SynchronizationProcessor test = new SynchronizationProcessor();
	private Object object;
	private SynchronizationThread syncThread = SynchronizationThread.getSyncThread();
	
	//Returns the singleton object
	public static SynchronizationProcessor GetTest(){
		return test;
	} 
	
	//private constructor
	private SynchronizationProcessor(){
	    queue = Queue.getQueue();
		syncThread.start();
	}
	
	//Queues the objects
	public synchronized void setObject(Object object) {
		this.object = object;
		Update update = (Update)object;
		if(object != null){
			queue.enqueue(object);
			int count = queue.Size();
			System.out.println("Queued......" + count + " Update is: " + update.getData());
			notifyAll();
		}
		
	}

	//Returns the object
	public Object getObject() {
		return object;
	}
}
